package com.example.study;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @description：
 * @author: liqiancheng
 * @createTime: 2021/8/19 10:32
 **/
public class HystrixMain {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        /**
         * 同步调用
         */
        String result = new MyHystrixCommand("zhangsan").execute();
        System.out.println(result);

        /**
         * 异步调用
         */
        Future<String> future = new MyHystrixCommand("zhangsan").queue();
        System.out.println(future.get());

        /**
         * 超时回退
         */
        String rollback= new MyHystrixCommand2("zhangsan").execute();
        System.out.println(rollback);
    }
}
